package kz.pompei.ifacer.util;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

public class HandlerListTest {
  @Test
  public void testall() throws Exception {
    KillingList<Integer> list = new KillingList<Integer>() {
      @Override
      public String toString() {
        List<Integer> lst = new ArrayList<>();
        for (Integer x : this) {
          lst.add(x);
        }
        return lst.toString();
      }
    };
    
    assertEquals("[]", list.toString());
    Killer kill1 = list.add(1);
    assertEquals("[1]", list.toString());
    Killer kill2 = list.add(2);
    assertEquals("[1, 2]", list.toString());
    kill1.kill();
    assertEquals("[2]", list.toString());
    kill2.kill();
    assertEquals("[]", list.toString());
  }
}
